#!/bin/sh

[ -f openssl.cnf ] && CONF="-config openssl.cnf" || CONF=

# generate a self-signed X509 certificate
openssl req $CONF -new -x509 -newkey rsa:1024 -days 365 \
    -outform PEM -out server.pem -keyout privkey.pem

# You can view certificate and private key in text format 
#   openssl x509 -in server.pem -text -noout
#   openssl rsa -in privkey.pem -text -noout

# remove the pass phrase on the RSA private key
openssl rsa -in privkey.pem -out privkey.pem

cat privkey.pem >> server.pem
rm privkey.pem

# .p12 files can be imported into FireFox or MSIE as personal
# certificate.
openssl pkcs12 -export -in server.pem -out server.p12 -name "For EBBS"

# openssl s_server -accept 443 -cert server.pem -verify -www

